<?php
/**
 * table_posts 表数据接口类，提供对posts表数据的CRUD操作
 *
 */

// {{{ include
FLEA::loadClass( 'FLEA_Db_TableDataGateway' );
// }}}

class table_posts extends FLEA_Db_TableDataGateway
{
	var $tableName = 'posts';
	var $primaryKey = 'post_id';

	var $hasMany = array(
		array(
			'tableClass' => 'table_comments',
			'foreignKey' => 'comment_id',
			'mappingName' => 'comments',
			'enabled' => false,
			// enableLink() 参数就是关联的 mappingName
	    //此句在关联操作前调用 $table->enableLink('comments');
		),
		array(
            'tableClass' => 'table_attachments',
            'foreignKey' => 'attach_id',
            'mappingName' => 'attachments',
            'enabled' => false,
            // enableLink() 参数就是关联的 mappingName
        //此句在关联操作前调用 $table->enableLink('attachments');
        )
	);

	var $manyToMany = array(
        array(
            'tableClass' => 'table_tags',
            'mappingName' => 'tags',
            'joinTable' => 'posts_has_tags',
            'counterCache' => 'tags_count'
        )
    );

}